package com.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sfzy.entity.ClassQaQuestion;
import com.sfzy.mapper.ClassQaQuestionMapper;
import com.sfzy.service.ClassQaQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassQaQuestionServiceImpl implements ClassQaQuestionService {
    @Autowired
    private ClassQaQuestionMapper classQaQuestionMapper;

    @Override
    public int addClassQaQuestion(ClassQaQuestion classQaQuestion) {
        return classQaQuestionMapper.addClassQaQuestion(classQaQuestion);
    }

    @Override
    public int deleteClassQaQuestionById(int id) {
        return classQaQuestionMapper.deleteClassQaQuestionById(id);
    }

    @Override
    public int updateClassQaQuestion(ClassQaQuestion classQaQuestion) {
        return classQaQuestionMapper.updateClassQaQuestion(classQaQuestion);
    }

    @Override
    public ClassQaQuestion getClassQaQuestionById(int id) {
        return classQaQuestionMapper.getClassQaQuestionById(id);
    }

    @Override
    public PageInfo<ClassQaQuestion> getByPage(ClassQaQuestion classQaQuestion, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ClassQaQuestion> classQaQuestions = classQaQuestionMapper.getByPage(classQaQuestion);
        PageInfo<ClassQaQuestion> pageInfo = new PageInfo<>(classQaQuestions);
        return pageInfo;
    }
}
